#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT(gfw, 1.0, rain.footprint@gmail.com)
AC_CONFIG_SRCDIR([md5/md5.h])
AC_CONFIG_HEADER([acconfig.h])
#manual add 
AM_INIT_AUTOMAKE(gfw,1.0)

if test `uname -s` = Linux ; then
  AC_MSG_NOTICE([congratulations, your system is Linux.])
else
  AC_ERROR([I am sorry, GreatFireWall can only run in Linux now])
fi

# Checks for programs.
AC_PROG_CC

# Checks for libraries.
#manual add 
AC_CHECK_LIB([pthread], [pthread_rwlock_init])

PKG_CHECK_MODULES(xml2, [libxml-2.0])
dnl check libxml
HAVE_LIBXML=no
AC_CHECK_LIB(xml2, xmlParseFile, HAVE_LIBXML="yes")
if test "x$HAVE_LIBXML" = xno; then
  AC_ERROR([libxml2 development package  is required to build GreatFireWall.])
fi

dnl check libwnck
HAVE_LIBWNCK=no
AC_CHECK_LIB(wnck-1, wnck_window_get_icon, HAVE_LIBWNCK="yes")
if test "x$HAVE_LIBWNCK" = xno; then
  AC_ERROR([libwnck development package  is required to build GreatFireWall.])
fi

AC_PROG_RANLIB
#

# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h libintl.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])

dnl check libgtk+-2.0
PKG_CHECK_MODULES(GTK,gtk+-2.0   gdk-2.0  gthread-2.0 ,  , exit)

dnl check libipq.h
dnl AC_CHECK_HEADERS(speex.h,[AC_CHECK_LIB(speex,speex_encode_int,speex_found=yes,speex_found=no)
AC_CHECK_HEADERS(libipq.h,libipq_found=yes,libipq_found=no)

if test "$libipq_found" = "no" ; then
AC_CHECK_HEADERS(libipq/libipq.h,libipq_found=yes,libipq_found=no)
else
AC_DEFINE(HAVE_LIBIPQ_PATH1,1,[libipq.h at /usr/include/libipq.h])
fi

if test "$libipq_found" = "no" ; then
dnl AC_MSG_WARN([libipq development package  is required to build GreatFireWall, please install first])
AC_MSG_ERROR([libipq development package  is required to build GreatFireWall, but not find in your system, please install first])
fi


# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME

# Checks for library functions.
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_MALLOC
AC_FUNC_SELECT_ARGTYPES
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([atexit memset select socket strchr strerror strrchr strstr strtol])

AC_CONFIG_FILES([Makefile
                 gui/Makefile
                 md5/Makefile
                 rules/Makefile
                 src/Makefile
                 xml/Makefile])
AC_OUTPUT
